package flatlandRPGTest;

import java.awt.Dimension;
import flatlandRPG.GameText;
import flatlandRPG.DrawPanel;
import flatlandRPG.MyGame;
import student.*;

// -------------------------------------------------------------------------
/**
 * Tests the MyGame class.
 *
 * @author evant
 * @version May 1, 2011
 */
public class GameTest
    extends GUITestCase
{
    private MyGame game;


    public void setUp()
    {
        DrawPanel panel = new DrawPanel();
        panel.setBounds(0, 0, 800, 600);
        showInFrame(panel, new Dimension(810, 610));
        game = new MyGame(800, 600, panel, new GameText(100));
    }


    // ----------------------------------------------------------
    /**
     * Tests that the game properly starts and stops.
     */
    public void testRunning()
    {
        Thread gameThread = new Thread() {
            public void run()
            {
                game.execute();
            }
        };
        gameThread.start();
        try
        {
            Thread.sleep(100);
        }
        catch (InterruptedException e)
        {
            e.printStackTrace();
        }
        assertTrue(game.isRunning());

        game.stop();

        assertFalse(game.isRunning());
    }
}
